package com.qf.controller;


import com.qf.pojo.City;
import com.qf.service.CityService;
import com.qf.util.Basedata;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@ResponseBody
@Controller
@RequestMapping("/city")
public class CityController {

    @Autowired
    CityService cityService;

    @RequestMapping("/citys")
    public Basedata selectAllCity(Integer pid){
        List list = cityService.SelectAllCity(pid);
        return new Basedata(1,list);
    }

    @RequestMapping("/getAndBackCity")
    public Basedata getAndBackCity(Integer getid,Integer backid){
        City getCity = cityService.getAndBackCity(getid);
        City backCity = cityService.getAndBackCity(backid);
        ArrayList<City> cities = new ArrayList<>();
        cities.add(getCity);
        cities.add(backCity);
        return new Basedata(1,cities);
    }

}
